{extend name='public/base'}
{block name='content'}

    <!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        {$item['item1']}
        <small>{$item['item2']}</small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> {$item['item1']}</a></li>
        <li class="active">{$item['item2']}</li>
      </ol>
    </section>

    <!-- Main content -->
    <section class="content">
        <div class="panel panel-default">
            <div class="panel-heading">
                <h3 class="panel-title">搜索栏</h3>
            </div>
    
            <form class="form-horizontal layui-form" action="{:url('admin/drug/index')}" method="get">
                <div class="box-body" style="padding: 15px;">
                    <div>
                        <div class="col-sm-2">
                            <input type="text" name="name" value="{$name|default=''}" class="form-control" placeholder="请输入药物名称">
                        </div>
                        <div class="col-sm-2">
                            <select name="drug_type" id="drug_type" >
                              <option value="">状态</option>
                              <option value="0">中药</option>
                              <option value="1">西成药</option>
                              <option value="2">收费项目</option>
                            </select>
                        </div>
    
                        <div class="col-sm-1">
                            <button type="submit" class="layui-btn layui-btn-sm layui-btn-warm">搜索</button>
                        </div>
                        
                    </div>
                </div>
            </form>
            <!-- <div class="col-sm-1">
              <button id="import" class="layui-btn layui-btn-sm layui-btn-warm">药品导入</button>
            </div> -->
            
        </div>
        
        <blockquote class="layui-elem-quote layui-text clw">
            <form class="form-horizontal layui-form" action="{:url('admin/drug/export')}" method="post">
              <div class="box-body">
                  <div>
                      <div class="col-sm-2">
                          <input type="text" name="name" value="{$name|default=''}" class="form-control" placeholder="请输入药物名称">
                      </div>
                      <div class="col-sm-2">
                          <select name="drug_type" id="drug_type" >
                            <option value="">状态</option>
                            <option value="0">中药</option>
                            <option value="1">西成药</option>
                            <option value="2">收费项目</option>
                          </select>
                      </div>
  
                      <div class="col-sm-1">
                          <button lay-filter="toSubmit" class="layui-btn layui-btn-sm layui-btn-warm">确定导出</button>
                      </div>
                  </div>
              </div>
          </form>
        </blockquote> 

      <div class="row" >
        <div class="col-xs-12">
          <!-- /.box -->
          <div class="box">
            <div class="box-header">
              <h3 class="box-title">药物列表</h3>
            </div>
            <div class="box-header">
                <button onclick="javascript:location.reload()" class="btn btn-info btn-sm">刷新</button>
            </div>
            <!-- /.box-header -->
            <div class="box-body">
              <table id="example1" class="table table-bordered table-hover table-striped">
                <thead>
                <tr>
                  <th>编号</th>
                  <th>诊所</th>
                  <th>名称</th>
                  <th>类型</th>
                  <th>使用方法</th>
                  <th>单位</th>
                  <th>单价</th> 
                  <th>斗位</th> 
                  <th>拼音</th> 
                  <!-- <th>库存</th>  -->
                  <th>规格</th> 
                  <th>备注</th>  
                  <th>添加时间</th>                 
                  <th>操作</th>
                </tr>
                </thead>
                <tbody>
                  {volist name='list' id='vo'}
                  <tr >
                    <td>{$vo.id}</td>
                    <!-- 调用公共方法settled_name，$vo.settled_id作为参数。 参考手册：模板->使用函数https://www.kancloud.cn/manual/thinkphp5/125005 -->
                    <td>{$vo.settled_id | settled_name}</td>
                    <td>{$vo.name}</td>
                    <td>
                      {eq name="vo.drug_type" value="0"}
                        中药
                      {/eq}
                      {eq name="vo.drug_type" value="1"}
                        西成药
                      {/eq}
                      {eq name="vo.drug_type" value="2"}
                        收费项目
                      {/eq}
                    </td>
                    <td>{$vo.method}</td>
                    <td>{$vo.unit}</td>
                    <td>{$vo.price}</td>
                    <td>{$vo.bucket}</td>
                    <td>{$vo.pinyin}</td>
                    <!-- <td>{$vo.stock}</td> -->
                    <td>{$vo.spec}</td>
                    <td>{$vo.remarks}</td>
                    <td>{$vo.time}</td>
                    <td>
                       <!--  <button onclick="lotus_show('用户详情','edit_user.html?id={$vo.id}',800,600)" class="btn btn-xs  btn-success btn-small">查看</button> -->
                        <button onclick='delete_user({$vo.id})' class="btn btn-xs  btn-danger btn-small">删除</button>
                    </td>
                  </tr>
                  {/volist}

                </tbody>

              </table>
              {$list->render()}
            </div>
            <!-- /.box-body -->
          </div>
          <!-- /.box -->
        </div>
        <!-- /.col -->
      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->


{/block}


{block name='script'}
<script>
    //删除用户
    function delete_user(id){
       layer.confirm('真的删除行么', function(index){
            $.ajax({
              url: '{:url("delete")}',
              type: 'get',
              dataType: 'json',
              data: {id:id},
          })
          .done(function(data){
              //回调提示
              if(data.code==0){
                      layer.msg(data.msg,{icon:2,time:1000});
                  }else{
                      layer.msg(data.msg,{icon:1,time:1500},function(){
                           location.reload();
                      });
              }
          })


       })

    }
    var importT = $('#import');
    importT.on('click',function(e){
      e.stopPropagation();
      $.ajax({
        url: '{:url("savestudentImport")}',
        type: 'get',
        dataType: 'json',
        // data: { id: id },
      })
    })



</script>
{/block}